package com.situ.stmall.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import com.situ.stmall.entity.Goods;
import com.situ.stmall.mapper.GoodsMapper;
import com.situ.stmall.service.GoodsService;

@Controller
public class GoodsController {

	@Autowired
	private GoodsService goodsService;
	
	@GetMapping("/search")
	public String search() {
		return "search";
	}
	
	@GetMapping("/goods")
	public String goods(Integer id,Model model) {
		//使用同步的方式获取数据
		//根据ID查询商品的详细信息
		Goods goods = goodsService.getById(id);
		
		model.addAttribute("goods", goods);
		return "goods";
	}
}
